
<div id="form"></div>
<script>
var grid;
var frm=$("#form").ajajform({
	header: "{{!title_edit_message}}",
	submit: {
		url: '/admin-guestbook_messages/',
		value: "Save",
		ajaj: true,
		params: {mode: "save",guestbook_id: '{{fields.guestbook_id}}', message_id: '{{fields.message_id}}', ajaj: 1},
	},
	footerButtons: 
	[{value: "delete", click: function() {if (confirm("Are you sure to delete?")) std_response($.ajax({type:"post",url: "/admin-guestbook_messages/",data:{mode: "delete",ajaj:1,guestbook_id: '{{fields.guestbook_id}}', message_id: '{{fields.message_id}}'},async:false}).responseText)} }]
		/* TODO TODO delete button */
	
});
frm.ajajform("insertWidget",null,null,{
	type: "label",
//	type: "textedit",
	name: "date_question",
	label: "{{!date_question}}",
	//validate: function(x) {if (!x || x.length==0) return "Empty name";},
	width: 500,
	value: "{{JS:message.date_question}}"
});
frm.ajajform("insertWidget",null,null,{
	type: "textedit",
	name: "user_q_name",
	label: "{{!user_q_name}}",
	validate: function(x) {if (!x || x.length==0) return "Empty name";},
	width: 500,
	value: "{{JS:message.user_q_name}}"
});
frm.ajajform("insertWidget",null,null,{
	type: "textedit",
	name: "user_q_phone",
	label: "{{!user_q_phone}}",
	width: 500,
	value: "{{JS:message.user_q_phone}}"
});
frm.ajajform("insertWidget",null,null,{
	type: "textedit",
	name: "user_q_email",
	label: "{{!user_q_email}}",
	width: 500,
	value: "{{JS:message.user_q_email}}"
});
frm.ajajform("insertWidget",null,null,{
	type:"file_id",
	name:"user_q_avatar_id",
	label:"{{!asker_image_id}}",
	width:600,
	value:{url:"{{message.user_q_avatar_id_url}}",name:"{{JS:message.user_q_avatar_id_name}}","id":"{{JS:message.user_q_avatar_id}}"},
	values:undefined
});
frm.ajajform("insertWidget",null,null,{
	type: "select",
	name: "user_a_id",
	label: "{{!user_a_id}}",
	width: 500,
	value: "{{JS:message.user_a_id}}",
	values: {{JSON:moderators}}
});
frm.ajajform("insertWidget",null,null,{
	type: "textareaedit",
	name: "question",
	label: "{{!question}}",
	width: 500,
	value: "{{JS:message.question}}"
});
frm.ajajform("insertWidget",null,null,{
	type: "textareaedit",
	name: "answer",
	label: "{{!answer}}",
	width: 500,
	value: "{{JS:message.answer}}"
});
frm.ajajform("insertWidget",null,null,{
	type: "date",
	name: "date_answer",
	label: "{{!date_answer}}",
	width: 200,
	value: "{{JS:message.date_answer}}"
});
frm.ajajform("insertWidget",null,null,{
	type: "checkbox",
	name: "moderated",
	label: "{{!moderated}}",
	width: 500,
	value: "{{JS:message.moderated}}"
});

</script>

